/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：呼叫中心-业务逻辑层-工作台-接口定义
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taiping.cc.platform.service;

import com.taiping.cc.platform.openfeign.fallbackfactory.PlatformServiceFallbackFactory;
import com.taipingframework.boot.web.response.result.ApiResult;
import com.taipingframework.utility.exception.ServiceException;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;

@FeignClient(value = "cc-platform-service",
        path = "/service/platform",
        contextId = "platformServiceContext",
        fallbackFactory = PlatformServiceFallbackFactory.class
)
public interface PlatformService {

    /**
     * 查询工作台数据
     */
    @ResponseBody
    @PostMapping(value = "/queryForActionDataList", consumes = {MediaType.APPLICATION_JSON_VALUE})
    ApiResult<TreeMap<String, String>> queryForActionDataList() throws ServiceException;

    /**
     * 分布式全局唯一ID生成
     */
    @ResponseBody
    @PostMapping(value = "/list/unid", consumes = {MediaType.APPLICATION_JSON_VALUE})
    ApiResult<ArrayList<String>> unidList() throws ServiceException;

    /**
     * 分布式锁解决方案 - redis
     */
    @ResponseBody
    @PostMapping(value = "/lock/redis", consumes = {MediaType.APPLICATION_JSON_VALUE})
    ApiResult<Boolean> redisLock() throws ServiceException;

    /**
     * 分布式锁解决方案 - zookeeper
     */
    @ResponseBody
    @PostMapping(value = "/lock/zk", consumes = {MediaType.APPLICATION_JSON_VALUE})
    ApiResult<Boolean> zkLock() throws ServiceException;

    /**
     * minio文件上传服务
     */
    @ResponseBody
    @PostMapping(value = "/file/upload", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
    ApiResult<HashMap<String, String>> uploadAttachment(MultipartFile file) throws ServiceException;

    /**
     * minio文件下载服务
     */
    @ResponseBody
    @GetMapping(value = "/file/download/{object_name}", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}, produces = {MediaType.APPLICATION_OCTET_STREAM_VALUE})
    ResponseEntity<Resource> downloadAttachment(@PathVariable("object_name") String objectName) throws ServiceException;

}
